<template>
    <div id="main" style="width: 98%; height: 95%; background-color: #ffff;"></div>
</template>

<script setup>
import * as echarts from 'echarts';
import { ref, onMounted } from 'vue';
import { Add } from '../units/api';
//图表
const monty = ref([])
const naam = ref([])
async function List() {
    let res = await Add({})
   
    for (let i = 0; i < res.data.data.taskCountOfMonth.length; i++) {
        monty.value.push(res.data.data.taskCountOfMonth[i].month)
        naam.value.push(res.data.data.taskCountOfMonth[i].count)
    }
    // console.log(res.data.data.taskCountOfMonth)
    opo()
    // option.xAxis.data.push(monty.value)
    // option.series[0].data.push(naam.value)
    console.log('990099090', res)

}

function opo() {
    var chartDom = document.getElementById('main');
    var myChart = echarts.init(chartDom);
    const option = {
        xAxis: {
            type: 'category',
            data: monty.value
        },
        legend: {
            data: ['任务数'],
            right: '5%'
        },
        yAxis: {
            type: 'value'
        },
        series: [
            {
                name: '任务数',
                data: naam.value,
                type: 'line',
                smooth: true,
                areaStyle: {}
            }
        ]
    };
    option && myChart.setOption(option);
}

List()
onMounted(() => {
    //main





})

</script>

<style lang="scss" scoped></style>